<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">    
    <title>IFE ECMAScript</title>
</head>
<body>        
    <input id="dec-number" type="number" placeholder="输入一个十进制非负整数">
    <button id="trans-btn">转化为二进制</button>
    <p id="result" >运算结果:</p>
    <script>
var num=document.getElementById('dec-number');
var transbtn= document.getElementById('trans-btn');
var result= document.getElementById('result');
transbtn.onclick=function() {
   if (num.value<0) {
     alert('输入一个十进制非负整数');
   } else {
    
    result.innerHTML=result.innerHTML+ parseInt(num.value).toString(2);
   } 
}

// 实现党点击转化按钮时，将输入的十进制数字转化为二进制，并显示在result的p标签内
// Some coding


    </script>
</body>
</html>